import {Form, Radio} from 'antd'
import {omit} from 'ramda'

const RadioGroup = Radio.Group;

const FormItem = Form.Item;

// type CheckboxPropsType = {
//     initialValue?: boolean,
//     name: string,
//     labelCol?: number,
//     options: Array<({ value: any, displayValue: string | number })>,
//     required?: boolean,
//     getFieldDecorator: Function,
//     label?: string | number
// }


const FormRadioGroup = ({required, options, getFieldDecorator, initialValue, name, labelCol, label}) => {

    return (
        <FormItem
            labelCol={{span: labelCol || 0}}
            wrapperCol={{span: 24 - (labelCol || 0)}}
            label={label}
        >
            {getFieldDecorator(name, {
                initialValue,
                rules: [{required, message: '必填项'}]
            })(
                <RadioGroup>
                    {(options || []).map(({value, displayValue}) => (
                        <Radio key={value} value={value}>{displayValue}</Radio>)
                    )}
                </RadioGroup>
            )}
        </FormItem>
    )
}

export default FormRadioGroup